package 反射注解.test02;

import java.lang.reflect.Method;

public class AnnotationTest02 {

    @MyAnnotation(username = "jojo",password = "123456")
    public void m1(){}

    public static void main(String[] args) {
        Class c = AnnotationTest02.class;
        try {
            Method m1Method = c.getDeclaredMethod("m1");
            if (m1Method.isAnnotationPresent(MyAnnotation.class)){
                MyAnnotation myAnnotation = m1Method.getAnnotation(MyAnnotation.class);
                System.out.println(myAnnotation.username());
                System.out.println(myAnnotation.password());
            }
        } catch (NoSuchMethodException e) {
            e.printStackTrace();
        }
    }
}
